<template>
  <div class="boxauth">
    <!-- 背景 -->
    <div class="bg"></div>
    <!-- 头部 -->
    <div class="htear">
      <div class="left">
        <div
          @click="$router.go(-1)"
          class="return iconfont icon-arrowRight-copy-copy"
        ></div>
        <div class="name">{{ name }}的主页</div>
      </div>
      <div class="right">
        <router-link
          tag="div"
          to="/search"
          class="searchcon iconfont icon-31sousuo"
        ></router-link>
        <div
          is-link
          @click="showPopup"
          class="classification iconfont icon-a-gengduofenlei"
        ></div>
      </div>
    </div>
    <!-- 弹出内容 -->
    <van-popup
      closeable
      v-model="show"
      position="top"
      :style="{ height: '45%' }"
    >
      <div class="boxpopup">
        <!-- 头部 -->
        <div class="htears">
          <div class="left">
            <div
              @click="$router.go(-1)"
              class="return iconfont icon-arrowRight-copy-copy"
            ></div>
            <div class="name">{{ name }}的主页</div>
          </div>
        </div>
        <!-- 分类 -->
        <div class="guide-nav">
          <router-link tag="div" to="/schoolboy" class="box">
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#icon-home-copy"></use>
            </svg>
            <div class="boxtext">首页</div>
          </router-link>
          <router-link tag="div" to="/classification" class="box">
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#icon-fenlei"></use>
            </svg>
            <div>分类</div>
          </router-link>
          <router-link tag="div" to="/rankinglist" class="box">
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#icon-daochu1024-02"></use>
            </svg>
            <div>排行榜</div>
          </router-link>
          <router-link tag="div" to="/cover" class="box">
            <svg class="icon" aria-hidden="true">
              <use
                xlink:href="#icon-a-travelhotelholidayvacationcdlistingboo"
              ></use>
            </svg>
            <div>免费</div>
          </router-link>
          <router-link tag="div" to="/end" class="box">
            <svg class="icon sw" aria-hidden="true">
              <use xlink:href="#icon-wanjietuijian"></use>
            </svg>
            <div>完本</div>
          </router-link>
          <router-link tag="div" to="/okami" class="box">
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#icon-huangguan"></use>
            </svg>
            <div>大神</div>
          </router-link>
        </div>
        <!-- 我的书架 -->
        <router-link tag="div" to="/bookshelf" class="mybookshelf">我的书架</router-link>
      </div>
    </van-popup>
    <!-- 封面 -->
    <div class="cover">
      <div class="img">
        <img :src="images" alt="" />
        <span>白金</span>
      </div>
      <div class="name">{{ name }}</div>
      <div class="text">
        {{ text }}
      </div>
      <div class="one-third">
        <div class="works">
          <span>作品数</span>
          <div>{{ numberworks }}</div>
        </div>
        <div class="works">
          <span>创作字数</span>
          <div>{{ numworks }}万</div>
        </div>
        <div class="works">
          <span>创作天数</span>
          <div>{{ days }}</div>
        </div>
      </div>
    </div>
    <!-- 推荐书籍 -->
    <div @click="bookdeta(item.id)"  v-for="item in wholelists.slice(0,1)" :key="item.id" class="recommends">
      <div class="reco">
        <div class="left">
          <img
            :src="item.img"
            alt=""
          />
        </div>
        <div class="right">
          <div class="top">{{ item.top }}</div>
          <div class="center">
            {{ item.bottom }}
          </div>
          <div class="bottom">第69章 爆发的许景明</div>
        </div>
      </div>
      <div class="reconer">
        <div class="left">本书粉丝</div>
        <div class="right">
          38.81万<span class="iconfont icon-arrowRight-copy-copy-copy"></span>
        </div>
      </div>
    </div>
    <!-- 全部作品 -->
    <div class="whole">
      <div class="namewh">{{ name }}的全部作品（{{ wholelists.length }}）</div>
      <ul>
        <li @click="bookdeta(item.id)" v-for="item in wholelists" :key="item.id">
          <div class="left">
            <img :src="item.img" alt="" />
          </div>
          <div class="right">
            <div class="top">{{ item.top }}</div>
            <div class="center">{{ item.center }}</div>
            <div class="bottom">{{ item.bottom }}</div>
          </div>
        </li>
      </ul>
    </div>
    <!-- 底部组件 -->
    <footers></footers>
  </div>
</template>

<script>
import footers from "../components/base/footers.vue";
export default {
  components: { footers },
  data() {
    return {
      //弹出判断
      show: false,
      wholelists: [],
      id: null, //作者ID
      name: null, //作者姓名
      text: null, //作者介绍
      images: null, //作者头像
      numberworks: null, //作者作品
      numworks: null, //作品字数
      days: null, //创作天数
    };
  },
  methods: {
    //头部弹出
    showPopup() {
      this.show = true;
    },
    // 路由跳转传参
    bookdeta(id) {
      this.$router.push({
        path: "/bookdetails",
        query: {
          id: id
        },
      });
    },
  },
  created() {
    this.id = this.$route.query.id;
    console.log(this.id)
    this.$axios.get("/static.json").then((res) => {
      let data = res.data;
      console.log(data.platinumlists[this.id]);
      if (this.id < 100) {
        console.log(data.platinumlists[this.id]);
        this.name = data.platinumlists[this.id].name; //作者姓名
        this.images = data.platinumlists[this.id].images; //作者头像
        this.text = data.platinumlists[this.id].text; //作者介绍
        this.wholelists = data.platinumlists[this.id].wholelists; //作者作品列表
        this.numberworks = data.platinumlists[this.id].wholelists.length; //作者作品列表
        this.numworks = data.platinumlists[this.id].numworks; //作者作品列表
        this.days = data.platinumlists[this.id].days; //作者作品列表
      } else {
        this.id -=100;//下标
        console.log(data.okamilists[this.id]);
        this.name = data.okamilists[this.id].name; //作者姓名
        this.images = data.okamilists[this.id].images; //作者头像
        this.text = data.okamilists[this.id].text; //作者介绍
        this.wholelists = data.okamilists[this.id].wholelists; //作者作品列表
        this.numberworks = data.okamilists[this.id].wholelists.length; //作者作品列表
        this.numworks = data.okamilists[this.id].numworks; //作者作品列表
        this.days = data.okamilists[this.id].days; //作者作品列表
      }
    });
  },
};
</script>

<style lang="less">
.boxauth {
  .boxpopup {
    .htears {
      width: 100%;
      display: flex;
      height: 22px;
      padding: 11px 0px 10px 0px;
      justify-content: space-between;
      align-items: center;
      .left,
      .right {
        display: flex;
        div {
          padding: 0px 10px;
          text-align: center;
          font-size: 18px;
          color: #3c3b3b;
        }
        .name {
          font-size: 14px;
          color: #424141;
        }
        .return {
          color: black;
        }
      }
    }
    .guide-nav {
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;
      padding: 0px 16px;
      .box {
        width: 58px;
        height: 58px;
        line-height: 58px;
        text-align: center;
        margin: 12px 24px;
        div {
          position: relative;
          top: -33px;
          font-size: 14px;
        }
      }
    }
    .mybookshelf {
      margin: 20px 50px;
      text-align: center;
      padding: 8px 0px;
      font-size: 14px;
      color: white;
      font-weight: 500;
      background-color: #ed424b;
      border-radius: 20px;
    }
    .sw {
      font-size: 40px;
    }
  }
  .htear {
    width: 100%;
    display: flex;
    height: 22px;
    padding: 11px 0px 10px 0px;
    justify-content: space-between;
    align-items: center;
    background-color: white;
    .left,
    .right {
      display: flex;
      div {
        padding: 0px 10px;
        text-align: center;
        font-size: 18px;
        color: #3c3b3b;
      }
      .name {
        font-size: 14px;
        color: #424141;
      }
      .return {
        color: black;
      }
    }
  }
  .cover {
    background-color: #fdfdfd;
    width: 100%;
    display: flex;
    align-items: center;
    flex-direction: column;
    .img {
      width: 64px;
      height: 64px;
      position: relative;
      display: flex;
      align-items: center;
      flex-direction: column;
      margin-bottom: 20px;
      border-radius: 50%;
      img {
        width: 100%;
        border-radius: 50%;
        box-shadow: 1px 0px 1px -1px black;
      }
      span {
        position: absolute;
        bottom: 0px;
        font-size: 12px;
        color: white;
        background-color: #b3a7ff;
        padding: 0px 7px 0px 7px;
        border-radius: 8px;
        border-top: 1px solid white;
        border-left: 1px solid white;
        border-right: 1px solid white;
      }
    }
    .name {
      font-size: 16px;
      color: #33373d;
      font-weight: 600;
    }
    .text {
      text-align: center;
      justify-content: center;
      width: calc(100% - 32px);
      margin: 10px 16px;
      color: #969ba3;
      font-size: 14px;
    }
    .one-third {
      width: calc(100% - 32px);
      display: flex;
      justify-content: center;
      padding: 0px 16px;
      padding-bottom: 12px;
      border-bottom: 1px solid #f3f2f2;
      .works {
        display: flex;
        align-items: center;
        flex-direction: column;
        padding: 0px 29px;
        justify-content: space-between;

        span {
          font-size: 12px;
          color: #969ba3;
          display: inline-block;
          transform: scale(0.8);
        }
        div {
          font-size: 16px;
          color: #33373d;
        }
      }
    }
  }
  .recommends {
    width: calc(100%);
    background: white;
    margin-bottom: 12px;
    .reco {
      width: calc(100% - 32px);
      padding: 16px 0px;
      padding-right: 16px;
      margin-left: 16px;
      display: flex;
      border-bottom: 1px solid #f3f3f3;
      .left {
        width: 66px;
        height: 88px;
        margin-right: 8px;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .right {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        .top {
          font-size: 16px;
          color: #33373d;
          font-weight: 600;
        }
        .center {
          line-height: 14px;
          display: -webkit-box;
          height: 29px;
          margin: 6px 0px;
          font-size: 14px;
          overflow: hidden;
          color: #969ba3;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 2;
        }
        .bottom {
          font-size: 14px;
          color: #33373d;
        }
      }
    }
    .reconer {
      width: calc(100% - 32px);
      padding: 10px 16px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .left {
        font-size: 16px;
        color: #33373d;
        font-weight: 600;
      }
      .right {
        font-size: 13px;
        color: #969ba3;
      }
    }
  }
  .whole {
    width: 100%;
    background-color: white;
    margin-bottom: 12px;
    .namewh {
      font-size: 16px;
      color: #33373d;
      font-weight: 600;
      padding: 12px 16px;
    }
    ul {
      li {
        width: calc(100% - 32px);
        padding: 16px 0px;
        padding-right: 16px;
        margin-left: 16px;
        display: flex;
        border-bottom: 1px solid #f3f3f3;
        .left {
          width: 66px;
          height: 88px;
          margin-right: 8px;
          img {
            width: 100%;
            height: 100%;
          }
        }
        .right {
          flex: 1;
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          .top {
            font-size: 16px;
            color: #33373d;
            font-weight: 600;
          }
          .center {
            font-size: 14px;
            color: #ed424b;
          }
          .bottom {
            line-height: 14px;
            display: -webkit-box;
            height: 29px;
            font-size: 14px;
            overflow: hidden;
            color: #969ba3;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
          }
        }
      }
    }
  }
}
</style>